import { fetchCommentsByPostId } from "@/prisma/queries/comments";
import CommentShow from "./comment-show";
interface CommentListParams {
  postId:string
}
export default async function CommentList({postId}:CommentListParams) {
  const comments = await fetchCommentsByPostId(postId)
  const topLevelComments = comments.filter(item => !item.parentId)
  return (
    <div className="space-y-3 !mt-10">
      <h1 className="text-lg font-bold">All 5 comments</h1>
      {/* 1 */}
      {topLevelComments.map(item => <CommentShow key={item.id} comment={item} />)}
    </div>
  );
}